From 2c2c6293f064b3544b048c17b473aa7ffafc69be Mon Sep 17 00:00:00 2001 From: "iap10@labyrinth.cl.cam.ac.uk" Date: Tue, 2 Dec 2003 16:29:59 +0000 Subject: [PATCH] bitkeeper revision 1.639 (3fccbe07JV6j1aK3O8_w92nf6uQSBw) Misc improvements to pincpu stuff. --- .rootkeys | 1 + tools/examples/destroydom.py | 0 tools/examples/listdoms.py | 0 tools/examples/mynewdom.py | 13 +++++++------ tools/examples/pincpu.py | 19 +++++++++++++++++-- tools/examples/startdom.py | 15 +++++++++++++++ tools/examples/stopdom.py | 0 tools/xc/py/XenoUtil.py | 17 ++++++----------- xen/common/dom0_ops.c | 11 +++++++---- 9 files changed, 53 insertions(+), 23 deletions(-) mode change 100644 => 100755 tools/examples/destroydom.py mode change 100644 => 100755 tools/examples/listdoms.py create mode 100755 tools/examples/startdom.py mode change 100644 => 100755 tools/examples/stopdom.py diff --git a/.rootkeys b/.rootkeys index f5af9fa921..b3264c9811 100644 --- a/.rootkeys +++ b/.rootkeys @@ -44,6 +44,7 @@ 3fbe2f12ltvweb13kBSsxqzZDAq4sg tools/examples/listdoms.py 3fca7788tBihusQSq3HJI-YKQTN2iQ tools/examples/mynewdom.py 3fca7700PVj36cZObaFZlQicRiw1pQ tools/examples/pincpu.py +3fccbe068ov0YCxnk-2m4law19QMmA tools/examples/startdom.py 3fbe2f12Bnt8mwmr1ZCP6HWGS6yvYw tools/examples/stopdom.py 3f776bd2Xd-dUcPKlPN2vG89VGtfvQ tools/misc/Makefile 3f6dc136ZKOjd8PIqLbFBl_v-rnkGg tools/misc/miniterm/Makefile diff --git a/tools/examples/destroydom.py b/tools/examples/destroydom.py old mode 100644 new mode 100755 diff --git a/tools/examples/listdoms.py b/tools/examples/listdoms.py old mode 100644 new mode 100755 diff --git a/tools/examples/mynewdom.py b/tools/examples/mynewdom.py index 49dba2d339..b3df7853bf 100755 --- a/tools/examples/mynewdom.py +++ b/tools/examples/mynewdom.py @@ -1,8 +1,9 @@ #!/usr/bin/env python -# -# Example script for creating and building a new Linux guest OS for Xen. -# +# Example script for creating and building a new Linux guest OS for +# Xen. THIS IS VERY SITE SPECIFIC, but shows an example configuration +# using multiple root partitions with a common /usr. e.g. Domain1 +# uses root /dev/sda8, usr /dev/sda6, and the next sequential IP address. import Xc, XenoUtil, sys, os, socket, re @@ -19,18 +20,18 @@ memory_megabytes = 64 # STEP 3. A handy name for your new domain. domain_name = "My new domain" -# Allocate new domain +# Allocate new domain ad get its domain id xc = Xc.new() id = xc.domain_create( mem_kb=memory_megabytes*1024, name=domain_name ) if id <= 0: print "Error creating domain" sys.exit() -# Set the CPU, or leave to round robin +# Set the CPU, or leave to round robin allocation #xc.domain_pincpu( dom=id, cpu=1 ) # STEP 4. Specify IP address, netmask and gateway for the new domain. -ipaddr = XenoUtil.add_to_ip(XenoUtil.addr_of_iface('eth0'),id) +ipaddr = XenoUtil.add_offset_to_ip(XenoUtil.get_current_ipaddr(),id) netmask = XenoUtil.get_current_ipmask() gateway = XenoUtil.get_current_ipgw() diff --git a/tools/examples/pincpu.py b/tools/examples/pincpu.py index d978067d72..f010f249c1 100755 --- a/tools/examples/pincpu.py +++ b/tools/examples/pincpu.py @@ -4,7 +4,7 @@ # Destroy specified domain. # -import Xc, sys, re +import Xc, sys, re, time xc = Xc.new() @@ -12,5 +12,20 @@ if len(sys.argv) < 3: print "Specify a domain identifier and CPU" sys.exit() -xc.domain_pincpu( dom=int(sys.argv[1]), cpu=int(sys.argv[2])) +dom = int(sys.argv[1]) +cpu = int(sys.argv[2]) + +orig_state = xc.domain_getinfo(first_dom=dom, max_doms=1)[0]['stopped'] + +while xc.domain_getinfo(first_dom=dom, max_doms=1)[0]['stopped'] != 1: + xc.domain_stop( dom=dom ) + time.sleep(0.1) + +xc.domain_pincpu( dom, cpu ) + +if orig_state == 0: + xc.domain_start( dom=dom ) + + + diff --git a/tools/examples/startdom.py b/tools/examples/startdom.py new file mode 100755 index 0000000000..0a4a53c974 --- /dev/null +++ b/tools/examples/startdom.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +# +# Start execution of specified domain. +# + +import Xc, sys, re + +xc = Xc.new() + +if len(sys.argv) != 2: + print "Specify a domain identifier" + sys.exit() + +xc.domain_start( dom=int(sys.argv[1]) ) diff --git a/tools/examples/stopdom.py b/tools/examples/stopdom.py old mode 100644 new mode 100755 diff --git a/tools/xc/py/XenoUtil.py b/tools/xc/py/XenoUtil.py index dfbcabc800..c49f859f5f 100644 --- a/tools/xc/py/XenoUtil.py +++ b/tools/xc/py/XenoUtil.py @@ -129,16 +129,11 @@ def setup_vfr_rules_for_vif(dom,vif,addr): os.close( fd ) return None -def addr_of_iface( iface ): - fd = os.popen( '/sbin/ifconfig '+iface ) - lines = fd.readlines() - for line in lines: - m = re.search( 'inet addr:([0-9.]+)', line ) - if m: - return m.group(1) - return None - -def add_to_ip( ip, off ): +def add_offset_to_ip( ip, off ): l = string.split(ip,'.') - return '%s.%s.%s.%d' % ( l[0],l[1],l[2],string.atoi(l[3])+off ) + a = ( (string.atoi(l[0])<<24) | (string.atoi(l[1])<<16) | + (string.atoi(l[2])<<8) | string.atoi(l[3]) ) + off + + return '%d.%d.%d.%d' % ( ((a>>24)&0xff), ((a>>16)&0xff), + ((a>>8)&0xff), (a&0xff) ) diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index 5f5e803c5a..2f3073a1c4 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -196,14 +196,17 @@ long do_dom0_op(dom0_op_t *u_dom0_op) else { /* For the moment, we are unable to move running - domains between CPUs. (We need a way of cleanly stopping - running domains). For now, if we discover the domain is - running then cowardly bail out with ENOSYS */ + domains between CPUs. (We need a way of synchronously + stopping running domains). For now, if we discover the + domain is not stopped already then cowardly bail out + with ENOSYS */ - if(p->flags & PF_CONSTRUCTED) + if( !(p->state & TASK_STOPPED) ) ret = -ENOSYS; else { + /* We need a task structure lock here!!! + FIX ME!! */ cpu = cpu % smp_num_cpus; p->processor = cpu; p->cpupinned = 1; -- 2.30.2